<template>
  <div>
    <el-form label-width="100px" class="form-table">
      <el-row>
        <el-col :span="6">
          <el-form-item label="状态">
            {{ borrower.status }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="创建时间">
            {{ borrower.createTime }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="姓名">
            {{ borrower.name }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="性别">
            {{ borrower.sex }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="年龄">
            {{ borrower.age }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="手机">
            {{ borrower.mobile }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="学历">
            {{ borrower.education }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="是否结婚">
            {{ borrower.marry }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="行业">
            {{ borrower.industry }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="还款来源">
            {{ borrower.returnSource }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="6">
          <el-form-item label="身份证号">
            {{ borrower.idCard }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人名称">
            {{ borrower.contactsName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人手机">
            {{ borrower.contactsMobile }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="联系人关系">
            {{ borrower.contactsRelation }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row v-for="item in borrower.borrowerAttachVos" :key="item.imageType">
        <el-col :span="24">
          <el-form-item :label="item.imageType">
            <span>
              <el-image
                style="width: 150px"
                :src="item.imageUrl"
                :preview-src-list="[item.imageUrl]"
              />
            </span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="text-align: center">
        <el-button @click="back">返回</el-button>
      </el-row>
    </el-form>
    <el-form label-width="150px" class="form-table">
      <el-form-item label="是否通过">
        <el-radio v-model="borrowerApprovalVO.status" :label="2">通过</el-radio>
        <el-radio v-model="borrowerApprovalVO.status" :label="-1">
          不通过
        </el-radio>
      </el-form-item>
      <el-form-item v-if="borrowerApprovalVO.status == 2" label="基本信息积分">
        <el-input
          v-model="borrowerApprovalVO.infoIntegral"
          style="width: 140px"
        />
        <span style="color: indianred">（可获取30至100积分）</span>
      </el-form-item>
      <el-form-item
        v-if="borrowerApprovalVO.status == 2"
        label="身份证信息是否正确"
      >
        <el-radio v-model="borrowerApprovalVO.isIdCardOk" :label="1">
          是
        </el-radio>
        <el-radio v-model="borrowerApprovalVO.isIdCardOk" :label="0">
          否
        </el-radio>
        <span style="color: indianred">（可获取30积分）</span>
      </el-form-item>
      <el-form-item
        v-if="borrowerApprovalVO.status == 2"
        label="车辆信息是否正确"
      >
        <el-radio v-model="borrowerApprovalVO.isCarOk" :label="1">是</el-radio>
        <el-radio v-model="borrowerApprovalVO.isCarOk" :label="0">否</el-radio>
        <span style="color: indianred">（可获取60积分）</span>
      </el-form-item>
      <el-form-item
        v-if="borrowerApprovalVO.status == 2"
        label="房产信息是否正确"
      >
        <el-radio v-model="borrowerApprovalVO.isHouseOk" :label="1">
          是
        </el-radio>
        <el-radio v-model="borrowerApprovalVO.isHouseOk" :label="0">
          否
        </el-radio>
        <span style="color: indianred">（可获取100积分）</span>
      </el-form-item>
      <el-form-item>
        <el-button :disabled="flag" @click="handleSubmit">确定</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import borrowerApi from '@/api/borrower'
export default {
  data() {
    return {
      flag: false,
      borrowerApprovalVO: {
        status: 2,
      },
      borrower: {},
    }
  },
  created() {
    this.getDetail(this.$route.params.id)
  },
  methods: {
    //提交审核数据
    handleSubmit() {
      this.flag = true //防止表单重复提交
      this.borrowerApprovalVO.borrowerId = this.$route.params.id
      // console.log(this.borrowerApprovalVO)
      borrowerApi.approval(this.borrowerApprovalVO).then((r) => {
        //提示成功  跳转到列表页
        this.$message.success(r.message)
        this.$router.push('/borrower/list')
      })
    },
    back() {
      //退回上一步的页面
      this.$router.push('/borrower/list')
    },
    getDetail(id) {
      borrowerApi.getDetail(id).then((r) => {
        console.log(r.data.item)
        this.borrower = r.data.item
      })
    },
  },
}
</script>
